//
//  ControlCenterTableVC.m
//  Recycling
//
//  Created by jzd on 2018/5/16.
//  Copyright © 2018年 宋佳. All rights reserved.
//

#import "ControlCenterTableVC.h"
#import "ControlCenterCell.h"
#import "controlCenterWorkVC.h"
#import "workerManagerVC.h"

@interface ControlCenterTableVC ()
@property(strong,nonatomic)NSArray *dataArray;

@end

@implementation ControlCenterTableVC
static NSString * const identify = @"controlCenterCell";
-(NSArray *)dataArray{
    if (_dataArray == nil) {
        _dataArray = @[@{@"title":@"工单管理",@"img":@"controlCenter1"},@{@"title":@"师傅管理",@"img":@"controlCentert2"}];
    }
    return _dataArray;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"管理中心";
    self.view.backgroundColor = BGCOLOR;
    [self.tableView registerNib:[UINib nibWithNibName:NSStringFromClass([ControlCenterCell class]) bundle:nil] forCellReuseIdentifier:identify];
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary *dict = [self.dataArray objectAtIndex:indexPath.row];
    ControlCenterCell *cell = [tableView dequeueReusableCellWithIdentifier:identify];
    [cell setCellInfo:dict];
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row == 0) {
        controlCenterWorkVC *vc = [[controlCenterWorkVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }else{
        workerManagerVC *vc = [[workerManagerVC alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}

@end
